log4j configuration file is not initialized under Classpath
Specify the location of the log4j.properties configuration file, while dynamically setting the output location of the log:
private static Logger Logger = null;
static{
//Set the environment variable property Wo
Category configuration in Log4j1/log4j2 and log output location (Windows and Linux common log output location) Category: Server Technology | Tags: windows| date: 2015-08-13 02:00:10
I. Scenarios and Requirements
Let's say I have 3 separate project (for the time being associated with Maven, and of course not maven), one is the infrastructure that provides the public service, one is the persister that provid
I used log4j in a struts project and posted it on Tomcat, but when I started Tomcat it was always impossible to specify the location of the log file.
If you specify this, when you start Tomcat, you always say that you cannot find the log file.
Log4j.appender.logfile.file=log/shitingguanai.log
If you specify the fol
= "Org.apache.log4j.RollingFileAppender"> paramname= "File"value= "D:/output.log" />set Log output file path (including file name) - set whether new logs are appended to the original log when the service is restarted - paramname= "Append"value= "true" /> paramname= "Maxbackupindex"value= "Ten" /> Layoutclass= "Org.apache.log4j
to the dimension output by % d {Num} And Num Class Name (for example, "org. apache. elattings. className ", % C {2} Will output elattings. className)% D: the log output time is in the format of % d {yyyy-MM-dd HH: mm: ss, SSS}. You can specify the format, for example, % d {HH: mm: ss}% L location of log event output, including category name, thread, number of lines in the code% N line break% M output code specified information, such as info ("message
Add log4j to Web. xml and log4j to Web. xml
The configuration file is as follows. Web. xml
The log4jproperties file exists and is also configured in webxml. Why does it still r
By default, the configuration file name of struts2 is called struts. XML, and the file is placed in the SRC root directory. As shown in:
To modify the location of Struts. XML, for example, put struts. xml in the struts2 folder, t
In web. XML, what is the difference between classpath: And classpath? Classpath: searches for files only in your class path. classpath *: not only contains the class path, but also contains the JAR file (class path. storage location: 1: SRC needs to be stored in web.
Log4j 2.0 advanced usage in development-read configuration file (6) and log4j usageIn log4j, the location where log files are stored is not necessarily under src, that is, under the root directory. In this case, we need to solve the problem of loading the configuration
method % d {iso8601}, % d {absolute}, % d {relative}. Or use the iso8601dateformat, absolutetimedateformat, relativetimedateformat, and datetimedateformat of log4j.
% F Class Name of the class to which the output log information belongs
% L location where the log event is output, that is, the number of lines in the class where the statement that outputs the log information is located
% M output the specifi
Og4j Advanced Tips-Location of dynamic configuration log output files
The usual use of log4j is to write the output file directly to death in its configuration file (XML or properties), which in many cases is very simple and effective. The disadvantage of this is that if y
of the log4j table in the database, the content % d (date) % C: log information location (Class Name) % P: log information level % m: generated log information % N: line feed of output log informationLog4j. appender. database. layout = org. Apache. log4j. patternlayoutLog4j. appender. database. layout. conversionpattern = [framework] % d-% C-%-4r [% T] %-5 p % C
information can be output, such as the designated day level for info, then info, WARN, ERROR, fatal log can be output.
②appender: Defines the destination of the log message output, specifying where the log message should be exported, either a console, a file, or a network device.
③layout: Specifies the output format of the log message.
The log4j configuration file
. conversionpattern = %-d {yyyy-mm-dd hh: mm: SS} [% C]-[% P] % m % N2. ========================================================== ========================================================== ============Next, I will provide a configuration process for using log4j in weblogic. First, I will provide the complete information of this configuration file.# Log4j. rootlo
Name of the class to which the output log information belongs% L location where the log event is output, that is, the number of lines in the class where the statement that outputs the log information is located% M output the specified information in the Code, such as the message in log (message)% N output a carriage return line break. For Windows, the value is "rn", and for Unix, the value is "n"% P output priority, that is, DEBUG, INFO, WARN, ERROR,
will make your application more flexible.LOG4J supports two configuration file formats, one in XML format and one in the properties format. Here's how to use the properties format as a configuration file:Example:Log4j.rootlogger=info, A1Log4j.appender.a1=org.apache.log4j.consoleappenderLog4j.appender.a1.layout=org.apache.log4j.patternlayoutLOG4J.APPENDER.A1.LAYOUT.CONVERSIONPATTERN=%-4R%-5p [%t] 7c%3x-%m%n
the configuration file is obtained by combining the log4j configuration file with the project path; the configuration information is read; and then "log4j" is reset. appender. file. file value, which is the path of the log input,
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.